Add xdg_init-free versions of some functions and use them internally, so
authorMatthias Clasen <mclasen@redhat.com>
Thu, 20 Jul 2006 04:14:59 +0000 (04:14 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 20 Jul 2006 04:14:59 +0000 (04:14 +0000)
2006-07-20  Matthias Clasen  <mclasen@redhat.com>

* xdgmimemagic.c:
* xdgmime.c:
* xdgmime.h: Add xdg_init-free versions of some
functions and use them internally, so that we don't
reload caches and clobber data structures in the
middle of an operation.  Patch by Joe Shaw,
bugs.freedesktop.org #6824

gtk/xdgmime/ChangeLog
gtk/xdgmime/xdgmime.c
gtk/xdgmime/xdgmime.h
gtk/xdgmime/xdgmimemagic.c

index f316e4b904c8e48366a3b2e061222139249e8666..0105cfafb2e2a3fc920e5a04f6511793f8fc9d4d 100644 (file)
@@ -1,3 +1,13 @@
+2006-07-20  Matthias Clasen  <mclasen@redhat.com>
+
+       * xdgmimemagic.c: 
+       * xdgmime.c: 
+       * xdgmime.h: Add xdg_init-free versions of some
+       functions and use them internally, so that we don't
+       reload caches and clobber data structures in the
+       middle of an operation.  Patch by Joe Shaw,
+       bugs.freedesktop.org #6824
+
 2006-07-19  Matthias Clasen  <mclasen@redhat.com>
 
        * xdgmimeglob.c (_xdg_glob_hash_node_lookup_file_name):
index 2cc1e68d274d315812ab1ceee76962605f96214a..16026cf1fd763f8b997fe84499e5d90f190dcb12 100644 (file)
@@ -602,12 +602,10 @@ xdg_mime_get_max_buffer_extents (void)
 }
 
 const char *
-xdg_mime_unalias_mime_type (const char *mime_type)
+_xdg_mime_unalias_mime_type (const char *mime_type)
 {
   const char *lookup;
 
-  xdg_mime_init ();
-
   if (_caches)
     return _xdg_mime_cache_unalias_mime_type (mime_type);
 
@@ -617,16 +615,22 @@ xdg_mime_unalias_mime_type (const char *mime_type)
   return mime_type;
 }
 
+const char *
+xdg_mime_unalias_mime_type (const char *mime_type)
+{
+  xdg_mime_init ();
+
+  return _xdg_mime_unalias_mime_type (mime_type);
+}
+
 int
-xdg_mime_mime_type_equal (const char *mime_a,
-                         const char *mime_b)
+_xdg_mime_mime_type_equal (const char *mime_a,
+                          const char *mime_b)
 {
   const char *unalias_a, *unalias_b;
 
-  xdg_mime_init ();
-
-  unalias_a = xdg_mime_unalias_mime_type (mime_a);
-  unalias_b = xdg_mime_unalias_mime_type (mime_b);
+  unalias_a = _xdg_mime_unalias_mime_type (mime_a);
+  unalias_b = _xdg_mime_unalias_mime_type (mime_b);
 
   if (strcmp (unalias_a, unalias_b) == 0)
     return 1;
@@ -634,6 +638,15 @@ xdg_mime_mime_type_equal (const char *mime_a,
   return 0;
 }
 
+int
+xdg_mime_mime_type_equal (const char *mime_a,
+                         const char *mime_b)
+{
+  xdg_mime_init ();
+
+  return _xdg_mime_mime_type_equal (mime_a, mime_b);
+}
+
 int
 xdg_mime_media_type_equal (const char *mime_a,
                           const char *mime_b)
@@ -668,19 +681,17 @@ xdg_mime_is_super_type (const char *mime)
 #endif
 
 int
-xdg_mime_mime_type_subclass (const char *mime,
-                            const char *base)
+_xdg_mime_mime_type_subclass (const char *mime,
+                             const char *base)
 {
   const char *umime, *ubase;
   const char **parents;
 
-  xdg_mime_init ();
-
   if (_caches)
     return _xdg_mime_cache_mime_type_subclass (mime, base);
 
-  umime = xdg_mime_unalias_mime_type (mime);
-  ubase = xdg_mime_unalias_mime_type (base);
+  umime = _xdg_mime_unalias_mime_type (mime);
+  ubase = _xdg_mime_unalias_mime_type (base);
 
   if (strcmp (umime, ubase) == 0)
     return 1;
@@ -703,13 +714,22 @@ xdg_mime_mime_type_subclass (const char *mime,
   parents = _xdg_mime_parent_list_lookup (parent_list, umime);
   for (; parents && *parents; parents++)
     {
-      if (xdg_mime_mime_type_subclass (*parents, ubase))
+      if (_xdg_mime_mime_type_subclass (*parents, ubase))
        return 1;
     }
 
   return 0;
 }
 
+int
+xdg_mime_mime_type_subclass (const char *mime,
+                            const char *base)
+{
+  xdg_mime_init ();
+
+  return _xdg_mime_mime_type_subclass (mime, base);
+}
+
 char **
 xdg_mime_list_mime_parents (const char *mime)
 {
@@ -741,7 +761,7 @@ xdg_mime_get_mime_parents (const char *mime)
 
   xdg_mime_init ();
 
-  umime = xdg_mime_unalias_mime_type (mime);
+  umime = _xdg_mime_unalias_mime_type (mime);
 
   return _xdg_mime_parent_list_lookup (parent_list, umime);
 }
index 2fa4a7cf39715b64bdb93ea36443288053b9e84a..d8172be25b214fe912ddf6c6adbe498e4abe88f0 100644 (file)
@@ -96,8 +96,16 @@ int          xdg_mime_register_reload_callback     (XdgMimeCallback  callback,
                                                    XdgMimeDestroy   destroy);
 void         xdg_mime_remove_callback              (int              callback_id);
 
+   /* Private versions of functions that don't call xdg_mime_init () */
+int          _xdg_mime_mime_type_equal             (const char *mime_a,
+                                                   const char *mime_b);
+int          _xdg_mime_media_type_equal            (const char *mime_a,
+                                                   const char *mime_b);
+int          _xdg_mime_mime_type_subclass          (const char *mime,
+                                                   const char *base);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
-
 #endif /* __XDG_MIME_H__ */
index 1718be78100c5160c43c2855dac18c0a3ffe869c..8258b2bb1bc814ff7f9dd632ea38d178b8a381b6 100644 (file)
@@ -664,7 +664,7 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
     {
       if (_xdg_mime_magic_match_compare_to_data (match, data, len))
        {
-         if ((mime_type == NULL) || (xdg_mime_mime_type_subclass (match->mime_type, mime_type))) {
+         if ((mime_type == NULL) || (_xdg_mime_mime_type_subclass (match->mime_type, mime_type))) {
            mime_type = match->mime_type;
          }
        }
@@ -673,7 +673,7 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
          for (n = 0; n < n_mime_types; n++)
            {
              if (mime_types[n] && 
-                 xdg_mime_mime_type_equal (mime_types[n], match->mime_type))
+                 _xdg_mime_mime_type_equal (mime_types[n], match->mime_type))
                mime_types[n] = NULL;
            }
        }